//
//  BDRedEnvelopeModel.m
//  BadBoy
//
//  Created by wen on 2017/7/13.
//  Copyright © 2017年 com.8xiong. All rights reserved.
//

#import "BDRedEnvelopeModel.h"

@implementation BDRedEnvelopeModel

+ (NSDictionary *)mj_replacedKeyFromPropertyName{
    return @{@"my_id":@"id"};
}

- (NSString *)endTimeString{
    if (!_endTimeString) {
        NSDate *date = [NSDate dateWithTimeIntervalSince1970:self.end_at];
        NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
        [dateFormat setDateFormat:@"yyyy-MM-dd"];//设定时间格式
        NSTimeZone *timeZone = [NSTimeZone localTimeZone];
        [dateFormat setTimeZone:timeZone];
        _endTimeString = [dateFormat stringFromDate:date];
    }
    return _endTimeString;
}

- (NSString *)conditions{
    NSComparisonResult result = [[NSDecimalNumber decimalNumberWithString:self.limit_money] compare:[NSDecimalNumber decimalNumberWithString:@"0"]];
    if (result > 0) {
        self.conditions = [NSString stringWithFormat:ASLocalizedString(@"使用条件：消费金额满%@元"), [NSDecimalNumber decimalNumberWithString:self.limit_money]];
    }else{
        self.conditions = ASLocalizedString(@"通用红包，无使用条件限制");
    }
    return _conditions;
}

@end
